#!/bin/bash -e

function info() {
echo Usage: `basename $0` '[-d -u -f] packages'
exit 1
}

while getopts  ":p:udf" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) force=--force-reinstall;;
        u) upgrade=--upgrade;;
        d) download=--download;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

# . $var

export PYTHONUSERBASE=$tools/py_module # python site.USER_BASE
export PIP_CACHE_DIR=$tools/py_module

pip install --user --ignore-installed $upgrade $force $*

# . $cmd_done



:<<test
tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
pip wheel -r requirements.txt --wheel-dir=$tempdir
cwd=`pwd`
(cd "$tempdir"; tar -cjvf "$cwd/bundled.tar.bz2" *)

tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
(cd $tempdir; tar -xvf $cmd/bundled.tar.bz2)
pip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps $tempdir/*

test